import React, { useState }  from 'react';
import './index.less';
import api from '../../../axios'
import { Row, Table, Modal, DatePicker, Divider, Button, Image,
  message,
  Descriptions,
Upload, } from 'antd';
  
import { InboxOutlined, UploadOutlined, LoadingOutlined, PlusOutlined } from '@ant-design/icons';

const formItemLayout = {
    labelCol: {
        span: 6,
    },
    wrapperCol: {
        span: 14,
    },
};
const normFile = (e) => {
    console.log('Upload event:', e);
    if (Array.isArray(e)) {
        return e;
    }
    return e?.fileList;
};

const getBase64 = (img, callback) => {
  const reader = new FileReader();
  reader.addEventListener('load', () => callback(reader.result));
  reader.readAsDataURL(img);
};
const beforeUpload = (file) => {
  const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
  if (!isJpgOrPng) {
    message.error('You can only upload JPG/PNG file!');
  }
  const isLt2M = file.size / 1024 / 1024 < 2;
  if (!isLt2M) {
    message.error('Image must smaller than 2MB!');
  }
  return isJpgOrPng && isLt2M;
};



class index extends React.Component {
    constructor(props) {
        super(props);
        this.state = { 
            visible: false,
            loading: true,
            fileloading: false,
            imageUrl: '',
            data: {}
        };
    }
    
    
    hideModal = () => {
        this.props.cancelModal()
    };

    componentDidMount(){
        this.getData()
    }


    getData = async () => {
        const { initialValues } = this.props
        let { data } = await api.get({
            method: 'get',
            url: `/activation/edit`,
            params: {
              id: initialValues.id,
            }
        });

        this.setState({
            data
        })
    } 


    
    render() {

        const { initialValues } = this.props
        const { imageUrl, fileloading, data } = this.state

        return (
           <>
             <Modal
                  title="显示详情"
                  width={800}
                  visible={true}
                  onCancel={this.hideModal}
                  onOk={() => this.onOk(this.state.data3)}
                  okText="保存"
                  footer={false}
                  cancelText="取消"
              >
                    <Descriptions title="详情">
                        <Descriptions.Item label="名称">{data.name}</Descriptions.Item>
                        <Descriptions.Item label="是否删除">{data.is_del}</Descriptions.Item>
                    </Descriptions>  
              </Modal>
           </>
        );
    }
}

export default index;